package fr.afcepf.vod.managedbean;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.primefaces.event.CloseEvent;
import org.primefaces.event.ToggleEvent;

import fr.afcepf.vod.entities.Tarifvideounite;
import fr.afcepf.vod.entities.Video;
import fr.afcepf.vod.metier.IGestionVideo;


@ManagedBean
@SessionScoped
public class MbCatalogue {
	
	@ManagedProperty(value="#{gestionVideoImpl}")
	private IGestionVideo gestionVideo;
	
	private List<Video> listVideo;
	
	private Video selectedVideo;
	private Tarifvideounite selectedTarif;
	
	private String msg;
	
	
	@PostConstruct
	public void initialiserPage(){
		listVideo = gestionVideo.getListVideo();
	}	

	public IGestionVideo getGestionVideo() {
		return gestionVideo;
	}

	public void setGestionVideo(IGestionVideo gestionVideo) {
		this.gestionVideo = gestionVideo;
	}
	
	public List<Video> getListVideo() {
		listVideo = gestionVideo.getListVideo();
		return listVideo;
	}

	public void setListVideo(List<Video> listVideo) {
		this.listVideo = listVideo;
	}

	public Video getSelectedVideo() {
		return selectedVideo;
	}

	public void setSelectedVideo(Video selectedVideo) {
		this.selectedVideo = selectedVideo;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public String videoChoisie() {
		setSelectedTarif(gestionVideo.getTarifVideo(selectedVideo.getIdVideo()));
	    return "InfoVideo.jsf";
	}
	
	public String videoChoisieClient() {
		setSelectedTarif(gestionVideo.getTarifVideo(selectedVideo.getIdVideo()));
	    return "InfoVideoClient.jsf";
	}	
	
	public String retourCatalogue() {
	    return "Catalogue.jsf";
	}
	
    public void handleClose(CloseEvent event) {  
        //FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Panel Closed", "Closed panel id:'" + event.getComponent().getId() + "'");  
          
        //addMessage(message);  
    }  
      
    public void handleToggle(ToggleEvent event) {  
        //FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, event.getComponent().getId() + " toggled", "Status:" + event.getVisibility().name());  
          
        //addMessage(message);  
    }

	public Tarifvideounite getSelectedTarif() {
		return selectedTarif;
	}

	public void setSelectedTarif(Tarifvideounite selectedTarif) {
		this.selectedTarif = selectedTarif;
	}  
      
}
